#include "stdafx.h"
#include "Band.h"

#include "Business/Bollinger.h"

Band::Band(double open,double offset,double stop) :m_open(open),m_offset(offset),m_stop(stop)
{
	if (m_stop < m_open) //bearish
	{
		m_openComparer = Comparer::less_equal;
		m_offsetComparer = Comparer::greater_equal;
		m_openStopComparer = Comparer::greater;
	}
	else //bullish
	{
		m_openComparer = Comparer::greater_equal;
		m_offsetComparer = Comparer::less_equal;
		m_openStopComparer = Comparer::less;
	}
}

void Band::UpdateByBollinger(Bollinger const& bollinger)
{
	if (m_stop < m_open) //bearish
	{
		m_open = bollinger.GetLower();
		m_offset = bollinger.GetUpper();
		m_stop = MORE_LOWER;
	}
	else //bullish
	{
		m_open = bollinger.GetUpper();
		m_offset = bollinger.GetLower();
		m_stop = MORE_UPPER;
	}

}